package ch.mtb.conwin;

public class MemoryGenome extends Genome {
	
	private int lastMove;
	
	public MemoryGenome(){
		super();
		lastMove = Config.getR().nextInt(8);
	}
	public MemoryGenome(int dNA[]) {
		initDna();
		reactions = dNA;
	}
	
	protected void initDna(){
		reactions = new int[8];

		for (int i = 0; i < 8; i++) {
			reactions[i] = Config.getR().nextInt(8);
			// System.out.println(reactions[i]);

		}
	
	}
	
	public Genome getClone() {
		int tempReactions[] = new int[8];

		for (int i = 0; i < 8; i++)
			tempReactions[i] = reactions[i];

		Genome temp = new MemoryGenome(tempReactions);

		return temp;

	}

	

	/**
	 * Which move is done depends solely on the last move
	 */

	public int react(int input) throws Exception {
		int retVal = reactions[lastMove];
		lastMove = reactions[lastMove];
		return (int) retVal;
	}

}
